<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<?php 
    @mysql_connect("localhost","root","") or die("数据库服务器连接出错！");
	@mysql_select_db("data") or die("数据库选择出错！");
	
	$un=$_POST['un'];
	$up=$_POST['up'];
	
	$querystr="select * from userinfo where username='$un' and userpass='$up'";

	$result=mysql_query($querystr) or die("数据库操作出错！");
	$con=mysql_fetch_array(mysql_query("select * from userinfo where username='$un' and userpass='$up'"));
	
	if($arr=mysql_fetch_array($result)){
		if ($con['usertype'] == 'teacher') {
			echo "登录成功！请进入<a href='teacher.html'>教师</a>系统<br/>";
		}
		elseif ($con['usertype'] == 'student') {
			echo "登录成功！请进入<a href='student.html'>学生</a>系统";
		}
		elseif ($un == 'admin') {
			echo "登录成功！请进入<a href='teacher.html'>教师</a>系统<br/>";
			echo "登录成功！请进入<a href='student.html'>学生</a>系统";
		}
		session_start();
		$_SESSION["login"]=1;
		$_SESSION["loginuser"]=$un;
	}
	else{
		 echo "用户名、密码错！请重新<a href='denglu.html'>登录</a>或<a href='zhuce.html'>注册</a>！";
	}
	
	mysql_close();
?>
</body>
</html>
